

package com.hazelcast.internal.config;

import com.hazelcast.config.ConfigRecognizer;
import com.hazelcast.config.ConfigStream;

import java.util.Collection;

/**
 * Abstract composite {@link ConfigRecognizer} implementation that uses
 * multiple recognizers under the hood.
 */
public class AbstractConfigRecognizer implements ConfigRecognizer {
    protected final Collection<ConfigRecognizer> recognizers;

    public AbstractConfigRecognizer(Collection<ConfigRecognizer> recognizers) {
        this.recognizers = recognizers;
    }

    @Override
    public boolean isRecognized(ConfigStream configStream) throws Exception {
        boolean recognized = false;
        for (ConfigRecognizer recognizer : recognizers) {
            configStream.reset();
            recognized = recognized || recognizer.isRecognized(configStream);
        }

        return recognized;
    }
}
